﻿/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework - CNR Framework Section
 * Version 2.10
 * 
 * CNR Error Event Arguments Class
 *      Provides an event arguments base class for CNR error events.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;
using Adaptive.Foundation;

namespace Adaptive.Foundation.Network.Cnr
{
    /// <summary>
    /// Provides an event arguments base class for CNR error events.
    /// </summary>
    /// <remarks>
    /// This class is intended to act as the base definition for the event arguments
    /// classes user to indicate that a protocol error has occurred (as opposed to 
    /// a managed exception).
    /// </remarks>
    public class CnrErrorEventArgs : System.EventArgs
    {
        /*--------------------------------------------------------------------------------
         * Private Member Declarations
         *------------------------------------------------------------------------------*/
        #region Private Member Declarations
        /// <summary>
        /// Error that occurred..
        /// </summary>
        private CnrErrorBase _error;
        /// <summary>
        /// Error message data.
        /// </summary>
        private string _message;
        #endregion

        /*--------------------------------------------------------------------------------
         * Constructor / Dispose / Destructor Methods
         *------------------------------------------------------------------------------*/
        #region Constructor / Dispose / Destructor Methods
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        public CnrErrorEventArgs()
            : base()
        {
            _message = string.Empty;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="error">
        /// The <see cref="T:CnrError"/> instance that occurred.
        /// </param>
        public CnrErrorEventArgs(CnrErrorBase error)
            : base()
        {
            _error = error;
            _message = string.Empty;

        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="message">Error message text.</param>
        public CnrErrorEventArgs(string message)
            : base()
        {
            _error = null;
            _message = message;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="error">
        /// A <see cref="T:CnrError"/> instance that ocurred.
        /// </param>
        /// <param name="message">Error message text.</param>
        public CnrErrorEventArgs(CnrErrorBase error, string message)
            : base()
        {
            _error = error;
            _message = message;
        }
        /// <summary>
        /// Class destructor.
        /// </summary>
        ~CnrErrorEventArgs()
        {
            _error = null;
            _message = null;
        }
        #endregion

        /*--------------------------------------------------------------------------------
         * Public Properties
         *------------------------------------------------------------------------------*/
        #region Public Properties
        /// <summary>
        /// Gets the reference to the protocol error instance that occurred.
        /// </summary>
        /// <value>
        /// A <see cref="CnrErrorBase"/> instance, or <b>null</b>.
        /// </value>
        public CnrErrorBase Error
        {
            get { return _error; }
        }
        /// <summary>
        /// Gets the message text associated with the error.
        /// </summary>
        /// <value>
        /// Error message text, an empty string, or <b>null</b>.
        /// </value>
        public string Message
        {
            get { return _message; }
        }
        #endregion
    }
}